home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mikecom / async.h < prev    next >
Text File  |  1987-05-19  |  8KB  |  166 lines

  1. .xlist
  2.  
  3. ;**** ASYNC.H --  Header file for all async functions.  Defines EQU's for
  4. ;                 various items & the __port_dta structure.
  5.  
  6. ;  Mike Dumdei,  6 Holly Lane,  Texarkana TX  75503
  7.  
  8. ;******************************************************************************
  9. ; Data definitions and data storage area.
  10. ;******************************************************************************
  11.  
  12. ;---- Lights for RX/TX
  13. ifdef LITES                             ;Define LITES only if using color
  14. ifdef MONO                              ;to get RX/TX indicators on bottom
  15. Vid_RX  equ     70h                     ;area of screen. Define LITES and
  16. Vid_TX  equ     70h                     ;MONO if using monochrome system.
  17. video_seg       segment at 0b000h
  18. video_seg       ends                    ;Use of onscreen indicators requires
  19. else                                    ;bottom 3 or 4 lines of screen to not
  20. Vid_RX  equ     40h                     ;be scrolled.
  21. Vid_TX  equ     50h
  22. video_seg       segment at 0b800h
  23. video_seg       ends
  24. endif
  25. endif
  26.  
  27. ;---- Location of com port base addresses in BIOS data area
  28. bios_dta        segment at 40h
  29.                 dw      2 dup(?)        ;base addr of comports accrdng to BIOS
  30. bios_dta        ends
  31.  
  32. ;---- Defininition of argument list for ASYNC functions
  33. Port            equ     wbp [BOFST]
  34.  
  35. BPDS_ptr        equ     wbp [BOFST+2]
  36. Tx_len          equ     wbp [BOFST+4]
  37. Rx_len          equ     wbp [BOFST+6]
  38.  
  39. TxChar          equ     bbp [BOFST+2]
  40.  
  41. Flag            equ     wbp [BOFST+2]
  42.  
  43. StatMask        equ     wbp [BOFST+2]
  44.  
  45. TxImdOfst       equ     wbp [BOFST+2]
  46. ifdef FARDATA
  47. TxImdSeg        equ     wbp [BOFST+4]
  48. TxImdCnt        equ     wbp [BOFST+6]
  49. else
  50. TxImdCnt        equ     wbp [BOFST+4]
  51. endif
  52.  
  53. MSRMntrFlg      equ     bbp [BOFST+2]
  54.  
  55. StripMask       equ     bbp [BOFST+2]
  56.  
  57. ;---- Return code equates
  58. R_OK              equ      0
  59. R_NOPORT          equ     -1
  60. R_PORTINUSE       equ     -2
  61. R_BAUDERR         equ     -3
  62. R_PARITYERR       equ     -4
  63. R_DTABITERR       equ     -5
  64. R_STPBITERR       equ     -6
  65. R_BADARG          equ     -7
  66. R_NOMEM           equ     -8
  67. R_TXERR           equ     -9
  68.  
  69. ;---- Miscellaneous equates
  70. OFF             equ     0               ;flag value when disabling a function
  71. MAXBUFSIZE      equ     32000           ;max rx/tx buf size
  72. MINTXBUFSIZ     equ     100             ;min tx buf size
  73. MINRXBUFSIZ     equ     750             ;min rx bufr size
  74. MAXPORT         equ     2               ;only supports COM1 or COM2
  75. XOFFCOUNT       equ     400             ;XOFF snt when ths much spc lft in rxbf
  76. XONCOUNT        equ     450             ;min free spc in rx buf befr XON sent
  77. REPTXOFFVAL     equ     160             ;# chars to rx aftr XOFF bfr resnd XOFF
  78. XONCHAR         equ     11h
  79. XOFFCHAR        equ     13h             ;XON/XOFF char values
  80. IMR_8259        equ     21h
  81. ICR_8259        equ     20h             ;addr of int cntrlr ports
  82. FLOW_MASK       equ     10110010b       ;used to ck for flow halts
  83. B_CD            equ     10000000b       ;carrier detect bit
  84. B_CTS           equ     00010000b       ;clear to send bit
  85. B_RTS           equ     00000010b       ;request to send bit
  86. B_DSR           equ     00100000b       ;data set ready bit
  87. B_DTR           equ     00000001b       ;data terminal ready bit
  88. B_TXEMPTY       equ     00001000b       ;nothing to transmit bit
  89. B_TXION         equ     00000001b       ;transmitter running bit
  90. B_XUSE          equ     00000001b       ;using XON/XOFF protocol bit
  91. B_XSENT         equ     00000100b       ;XOFF sent bit
  92. B_XRXD          equ     00000010b       ;XOFF received bit
  93. B_RXEMPTY       equ     01000000b       ;rx buffer empty bit
  94. B_RXOVF         equ     00000001b       ;rx buffer overflow indic bit
  95. B_FLOWHALT      equ     01000000b       ;flow halt indicator bit
  96. B_XONANY        equ     00000001b       ;any char can be XON bit
  97.  
  98. ;---- Definition of port data (SI must hold pointer to 'port_dta')
  99. COM_BASE        equ     wsi[0]   ;1)base port address of for comm port
  100. TX_TOP          equ     wsi[2]   ;2)ptr to beginning of tx buffer
  101. TX_BTM          equ     wsi[4]   ;3)ptr to end of tx buffer (end + 1)
  102. RX_TOP          equ     wsi[4]   ;3)ptr to begin of rx bufr
  103. RX_BTM          equ     wsi[6]   ;4)ptr to end of rx bufr (end + 1)
  104. TX_IN           equ     wsi[8]   ;5)ptr to where next 'put' goes
  105. TX_OUT          equ     wsi[10]  ;6)ptr to where next tx'd comes from
  106. TX_FREE         equ     wsi[12]  ;7)remaining tx bufr space
  107. TX_SIZE         equ     wsi[14]  ;8)total size of tx bufr
  108. RX_IN           equ     wsi[16]  ;9)ptr to where next rx'd goes
  109. RX_OUT          equ     wsi[18]  ;10)ptr to where next 'get' comes from
  110. RX_FREE         equ     wsi[20]  ;11)remaining bytes in rx bufr space
  111. RX_SIZE         equ     wsi[22]  ;12)total size of rx bufr
  112. RXTX_SEG        equ     wsi[24]  ;13)segment of rx/tx bufrs if FAR ptrs
  113. BAUD_DVSR       equ     wsi[26]  ;14)baud rate divisor
  114. OLDVCTR_SEG     equ     wsi[28]  ;15)segment addr of old int vector
  115. OLDVCTR_OFST    equ     wsi[30]  ;16)offset addr of old int vector
  116. NEWVCTR_SEG     equ     wsi[32]  ;17)segment of new int vector
  117. NEWVCTR_OFST    equ     wsi[34]  ;18)offset addr of new int vector
  118. VECTOR_NBR      equ     bsi[36]  ;19)vctr nmbr assoc with slctd com port
  119. MSK_8259        equ     bsi[37]  ;20)Mask to enable 8259 interrupt
  120. STATWRD1        equ     wsi[38]  ;21)stat bytes 1 and 2 (bit maps below)
  121. STAT2           equ     bsi[38]  ;21a)secondary status byte
  122. STAT1           equ     bsi[39]  ;21b)primary status byte
  123. STATWRD2        equ     wsi[40]  ;22)tx_stat & msr flow control mask bytes
  124. TX_STAT         equ     bsi[40]  ;22a)determines when tx_intrpts need turned on
  125. MSR_MASK        equ     bsi[41]  ;22b)slcts bits in MSR montrd for flow cntrl
  126. PDSINFO         equ     bsi[42]  ;23)parity, # dta bits, # stop bits
  127. XTXRPT          equ     bsi[43]  ;24)countdown val befr repeat tx of XOFF
  128. TXIMMEDCHAR     equ     bsi[44]  ;25)char to be tx'd 1st opportunity
  129. OLD_8259_MSK    equ     bsi[45]  ;26)original 8259 interrupt mask
  130. OLD_LCR         equ     bsi[46]  ;27)original Line Control Reg value
  131. OLD_MCR         equ     bsi[47]  ;28)original Modem Cntrl Reg value
  132. OLD_IER         equ     bsi[48]  ;29)original Interrupt Enable Reg value
  133. STRIP_MASK      equ     bsi[49]  ;30)mask for high bit stripping
  134. MSR_VAL         equ     bsi[50]  ;31)present value of modem status register
  135. STAT3           equ     bsi[51]  ;32)another flag -- mapped below
  136.  
  137. ;---- Bit maps of status bytes:
  138. ;-- Values returned by async_stat (1 & 2) and async_rx high byte (1 only)
  139. ;   STAT1: 0=rx bufr ovrfl   1=char overrun     2=parity err    3=framing err
  140. ;          4=break intrpt    5=invalid port     6=rx bufr empty 7=no carrier
  141. ;   STAT2: 0=XON/OFF in use  1=XOFF received    2=XOFF sent     3=tx buf empty
  142. ;          4=montr'g CTS     5=montr'g DSR      6=flw hlt actv  7=montr'g CD
  143. ;-- Flow bits in tx stat not being monitored are set to 0.  Whenever this byte
  144. ;   equals 0 a call is made to turn the transmitter on.
  145. ; TX_STAT: 0=tx intrpts on   1=XOFF rx'd        2=not used (0)  3=nothing to tx
  146. ;          4=not CTS         5=not DSR          6=not used (0)  7=not CD
  147. ;-- MSR_MASK bits set low to indic that signal is being monitored else are 1
  148. ;MSR_MASK: 0= 1              1= 1               2= 1            3= 1
  149. ;          4=CTS flow ckg    5=DSR flow ckg     6= 1            7= CD flow ckg
  150. ;-- Catch-all flag for anything left
  151. ;   STAT3: 0=any char XON    1=not used         2=not used      3=not used
  152. ;          4=not used        5=not used         6=not used      7=not used
  153.  
  154.  
  155.      ;Variables in structure separated to allow initialization for each port
  156.      ;Above equates show layout of data within the structure
  157. port_dta        struc
  158.                 dw      16 dup(0)
  159.                 dw      0               ;new vector segment location in struc
  160.                 dw      0               ;new vector offset location
  161.                 db      0               ;loc of vector number in struc
  162.                 db      0               ;Mask for IRQ number (8259)
  163.                 db      14 dup(0)
  164. port_dta        ends
  165. .list
  166.